{% extends "dashboard/base.html" %}
{% load i18n %}
{% load prices_i18n %}
{% load materializecss %}
{% load staticfiles %}

{% block title %}
  {% trans "Product types" context "Dashboard product types list" %} - {{ block.super }}
{% endblock %}

{% block body_class %}body-products{% endblock %}

{% block menu_product_classes_class %}active{% endblock %}

{% block header_extra %}
  <div class="fixed-action-btn">
    <a class="btn-fab btn-floating btn-large waves-effect waves-light teal" title="{% trans "Add product type" context "Product type list add button text" %}" href="{% url 'dashboard:product-class-add' %}">
      <svg data-src="{% static "dashboard/images/add.svg" %}" />
    </a>
  </div>
{% endblock %}

{% block breadcrumbs %}
  <ul class="breadcrumbs">
    <li class="visible-s">
      {% trans "Product types" context "Dashboard product types list" %}
    </li>
  </ul>
{% endblock %}

{% block menu_catalogue_class %} active{% endblock %}

{% block content %}
  <div class="row">
    <div class="col s12">
      {% if product_classes %}
        <ul class="collection list">
          {% for pk, name, has_variants, product_attributes, variant_attributes in product_classes %}
            <li class="collection-item list-item">
              <a class="title" href="{% url 'dashboard:product-class-update' pk=pk %}">
                <span class="list-item-name">
                  {{ name }}
                </span>
                <p class="list-item-desc">
                  {% trans "Variants" context "Dashboard variants" %}: 
                  {% if has_variants %}
                    {% trans "Yes" %}
                  {% else %}
                    {% trans "No" %}
                  {% endif %}
                  {% if variant_attributes %}
                    &middot; {% trans "Variant attributes" context "Product type item list text" %}: {{ variant_attributes|join:", " }}
                  {% endif %}
                  {% if product_attributes %}
                    &middot; {% trans "Product attributes" context "Product type item list text" %}: {{ product_attributes|join:", " }}
                  {% endif %}
                </p>
              </a>
            </li>
          {% endfor %}
        </ul>
        {% include "dashboard/includes/_pagination.html" with page_obj=product_classes %}
      {% else %}
        <div class="not-found">
          <p class="grey-text">
            {% trans "No product types found." context "Empty product type list message" %}
          </p>
        </div>
      {% endif %}
    </div>
  </div>
  <div id="modal-product-class" class="modal">
    <div class="modal-content">
      <form method="post" novalidate>
        {% csrf_token %}
        <div class="row">
          {{ form|materializecss }}
        </div>
        <div class="row">
          <div class="col s12">
            <button class="btn" type="submit">
              {% trans "Create new" context "Dashboard create new action"  %}
            </button>
          </div>
        </div>
      </form>
    </div>
  </div>
{% endblock %}
